using System;
using System.Data;
using System.Windows.Forms;
using PointOfSale.Global;
using PointOfSale.POSSystem;
using PointOfSale.Class;
using PointOfSale.Report.Cashier;

namespace PointOfSale.Report.Cashier
{
	public class frmCashiersReport : System.Windows.Forms.Form
	{
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.Button btnClose;
		private System.Windows.Forms.DialogResult ans;
		private System.Windows.Forms.ColumnHeader columnNo;
		private System.Windows.Forms.ColumnHeader columnPaid;
		private System.Windows.Forms.ColumnHeader columnPost;
		private System.Windows.Forms.ColumnHeader columnTotal;
		public System.Windows.Forms.ListView lsvCashier;
		
		private System.ComponentModel.Container components = null;

		public frmCashiersReport()
		{
			InitializeComponent();
		}

		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.lsvCashier = new System.Windows.Forms.ListView();
			this.columnNo = new System.Windows.Forms.ColumnHeader();
			this.columnPaid = new System.Windows.Forms.ColumnHeader();
			this.columnPost = new System.Windows.Forms.ColumnHeader();
			this.columnTotal = new System.Windows.Forms.ColumnHeader();
			this.btnClose = new System.Windows.Forms.Button();
			this.groupBox1.SuspendLayout();
			this.SuspendLayout();
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.Add(this.lsvCashier);
			this.groupBox1.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.groupBox1.Location = new System.Drawing.Point(8, 8);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(432, 256);
			this.groupBox1.TabIndex = 0;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "CashierReport";
			// 
			// lsvCashier
			// 
			this.lsvCashier.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
																						 this.columnNo,
																						 this.columnPaid,
																						 this.columnPost,
																						 this.columnTotal});
			this.lsvCashier.FullRowSelect = true;
			this.lsvCashier.GridLines = true;
			this.lsvCashier.Location = new System.Drawing.Point(8, 16);
			this.lsvCashier.Name = "lsvCashier";
			this.lsvCashier.Size = new System.Drawing.Size(424, 232);
			this.lsvCashier.TabIndex = 0;
			this.lsvCashier.View = System.Windows.Forms.View.Details;
			// 
			// columnNo
			// 
			this.columnNo.Text = "CashierNo";
			this.columnNo.Width = 92;
			// 
			// columnPaid
			// 
			this.columnPaid.Text = "CashierPaid";
			this.columnPaid.Width = 124;
			// 
			// columnPost
			// 
			this.columnPost.Text = "CashierPost";
			this.columnPost.Width = 97;
			// 
			// columnTotal
			// 
			this.columnTotal.Text = "CashierTotal";
			this.columnTotal.Width = 106;
			// 
			// btnClose
			// 
			this.btnClose.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.btnClose.Location = new System.Drawing.Point(328, 272);
			this.btnClose.Name = "btnClose";
			this.btnClose.TabIndex = 1;
			this.btnClose.Text = "OK";
			this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
			// 
			// frmCashiersReport
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(462, 302);
			this.Controls.Add(this.btnClose);
			this.Controls.Add(this.groupBox1);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "frmCashiersReport";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "Bao cao cuoi ca";
			this.Load += new System.EventHandler(this.frmCashiersReport_Load);
			this.groupBox1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void btnClose_Click(object sender, System.EventArgs e)
		{
			//Neu chuyen nguoi dung
			if(clsGlobal.g_isChangeUser)
			{
				this.Close();
				return;
			}
			
			//Neu thoat khoi he thong
			if(clsGlobal.g_isExit)
			{
				ans = MessageBox.Show(clsGlobal.g_Hashtable["msgCofirmExit"].ToString(),clsGlobal.g_Hashtable["ExitFormName"].ToString(),MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
//				if(ans == DialogResult.OK)
//				{
					clsGlobal.g_DataConn.Close();
					clsGlobal.g_Conn.Close();
					clsGlobal.g_HMS_DataConn.Close();
					this.Close();
					Application.Exit();
					Environment.Exit(0);
//				}
//				else
//				{
//					this.Close();
//				}
			}
		}

		private void frmCashiersReport_Load(object sender, System.EventArgs e)
		{
			DataTable dt = clsUser.DayReport(clsGlobal.g_UserId, clsGlobal.g_TimeIn);
			
			int n = dt.Rows.Count;
			for (int i = 0; i < n; i ++)
			{				
				ListViewItem lsvItem = new ListViewItem(dt.Rows[i][0].ToString());
				lsvItem.SubItems.Add(dt.Rows[i][0].ToString());
				lsvItem.SubItems.Add(dt.Rows[i][1].ToString());
				lsvItem.SubItems.Add(dt.Rows[i][2].ToString());
				lsvCashier.Items.Add(lsvItem);
			}
		}
	}
}
